Book Contents

Bitwise operators in expressions

Bitwise operators let you examine and manipulate individual bits within a value. These operators must only be applied to integers, not floating point numbers.

Symbol

Operator

Example

&

AND

tag1 & 07

|

inclusive OR

tag2 | tag1

^

exclusive OR (XOR)

tag1 ^ 01

>>

right shift

tag1 >> 1

<<

left shift

tag1 << 2

~

complement

~ tag1

Tip:

  • The bitwise operators &, |, and ^ compare two integers or tags on a bit by bit basis.
  • The bitwise operators >>, <<, and ~ operators manipulate a single integer or tag.

See also

About expressions

Example: Bitwise operators